<template>
	<view class="outer">
		<uni-title type="h1" :title="totalMoney" align="center"  color="#ff0000"></uni-title>
		<uni-data-select  v-model="value" :localdata="options" @change="change"></uni-data-select>
		<uni-list class="formList">
			<uni-list-item v-for="(item, index) in listList" :key="index" :title="item.lFamilyFriends.lRealName"
				:note="item.lGiftWay==0?'送礼'+' '+item.createTime.substr(0,10)+' '+item.remark:'收礼'+' '+item.createTime.substr(0,10)+' '+item.remark" :show-extra="true"
				showExtraIcon=true :rightText="item.lCashGift+''">
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import {
		listList,
		getList,
		delList,
		addList,
		updateList
	} from "@/api/home/gift";

    import {
		listFriends
	} from "@/api/home/friends";

	export default {
		data() {
			return {
				listList: [],
				total: 0,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 1000,
					lEventType: null,
					lPillarId: null,
					lGiftWay: null,
					lCashGift: null,
					lGift: null,
					lGiftDescription: null,
				},
				totalMoney: "0.00",
				value: 1,
				fParams: {
					pageNum: 1,
					pageSize: 1000,
				},
				options: [],
			}
		},
		created() {
			this.getList();
			this.getFriendList();
		},
		methods: {
			getList() {
				listList(this.queryParams).then(response => {
					console.log(response);
					this.listList = response.rows;
					this.total = response.total;
					this.totalMoney = "￥"+response.rows[0].totalMoney+"";
				});
			},
			getFriendList(){
				listFriends(this.fParams).then(response => {
					console.log(response);
					this.options = response.rows.map(option => {
						return {
							value:option.lUserId,
							text:option.lRealName,
						}
					})
				});
			},
			change(e) {
				this.queryParams.lPillarId = e;
				listList(this.queryParams).then(response => {
					console.log(response);
					this.listList = response.rows;
					this.total = response.total;
					if(response.rows.length>0){
						this.totalMoney = "￥"+response.rows[0].totalMoney+"";
					}else{
						this.totalMoney = "￥"+"0.00"
					}
					
				});
			},
		}
	}
</script>


<style>
	.outer {
		margin-left: 10px;
		margin-right: 10px;
		margin-top: 10px;
	}
	.formList{
		background: #ff0000;
	}
	
</style>